package com.mlog.njyjy.ndop.msg.persistence.dao;

import com.mlog.njyjy.ndop.msg.common.domain.Dict;
import com.mlog.njyjy.ndop.msg.common.domain.DictItem;
import com.mlog.njyjy.ndop.share.sql.dao.BaseSqlRepository;
import com.mlog.njyjy.ndop.share.sql.support.SqlTableUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * .
 * </p>
 *
 * @author <a href="mailto:yingxiufeng@mlogcn.com">alex</a>
 * @version v1.0, 2020/7/10
 */
@Repository
public class DictRepository extends BaseSqlRepository<Dict> {

    @Autowired
    private DictItemRepository dictItemRepository;

    /**
     * find {@link DictItem} by dict id
     *
     * @param dictId id of the dict
     * @return
     */
    public List<DictItem> findItems(Long dictId) {
        return dictItemRepository.find("select * from " + SqlTableUtil.getTblName(DictItem.class) + " where dict_id=?", dictId);
    }
}
